package com.ay.weixin.config.types;

import javax.servlet.ServletContext;

import org.lizar.Web;

public enum KanFangProgress {
	START(1, "开始"), PROGRESS(2, "进行中"), CLOSED(3, "结束"), CASH_RETURN(4, "已发佣金");
	private int		value;
	private String	desc;
	
	private KanFangProgress(int value, String desc) {
		this.value = value;
		this.desc = desc;
	}
	
	public static void loadToAppAttr() {
		ServletContext context = Web.context;
		context.setAttribute("progress_list", values());
		context.setAttribute("progress_start", START);
		context.setAttribute("progress_closed", CLOSED);
		context.setAttribute("progress_ongoing", PROGRESS);
		context.setAttribute("progress_cash_return", CASH_RETURN);
	}
	
	public static KanFangProgress getStatus(int status) {
		switch (status) {
			case 1:
				return START;
			case 2:
				return PROGRESS;
			case 3:
				return CLOSED;
			case 4:
				return CASH_RETURN;
		}
		return START;
	}
	
	public int getValue() {
		return value;
	}
	
	public void setValue(int value) {
		this.value = value;
	}
	
	public String getDesc() {
		return desc;
	}
	
	public void setDesc(String desc) {
		this.desc = desc;
	}
}
